using System;
using System.Collections.Generic;
using System.Text;

namespace DeflateLib
{
    /// <summary>
    /// Basic DEFLATE compressor: finds and packages substrings.
    /// </summary>
    /// <see cref="CharSequenceCompressor"/>
    /// <see cref="LZ77Compressor"/>
    public interface ICompressor
    {
        /// <summary>
        /// Pre-initializes compressor with data such as dictionary.
        /// </summary>
        /// <param name="data">data</param>
        /// <param name="index">offset with data</param>
        /// <param name="length">data length</param>
        void Initialize(byte[] data, int index, int length);

        /// <summary>
        /// Performs compressions. Has to returs compressed data class. 
        /// </summary>
        /// <param name="data">data</param>
        /// <param name="index">offset with data</param>
        /// <param name="length">data length</param>
        /// <returns>Result compressed data</returns>
        CompressedData Compress(byte[] data, int index, int length);
    }

    /// <summary>
    /// Factory for ICompressor base classes.
    /// </summary>
    /// <see cref="ICompressor"/>
    public abstract class CompressorFactory 
    {
        /// <summary>
        /// Gets default compressor factory.
        /// </summary>
        public static readonly CompressorFactory Default;

        static CompressorFactory()
        {
            CompressorFactory.Default = new LZ77CompressorFactory();
            //CompressorFactory.Instance = new CharSequenceCompressorFactory();
        }

        /// <summary>
        /// Creates compressor.
        /// </summary>
        /// <returns>Created compressor</returns>
        public abstract ICompressor CreateCompressor();
    }
}
